package com.dimples.controller.view;

import com.dimples.common.enums.ViewEnum;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

import lombok.RequiredArgsConstructor;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2020/2/28
 */
@RequiredArgsConstructor
@Controller
public class ViewController extends BaseWebController {

    @GetMapping(value = {WEB_PRE})
    public ModelAndView home() {
        return redirect(ViewEnum.LOGIN.getValue());
    }

    @GetMapping(WEB_PRE + "login")
    public ModelAndView login() {
        return toPage(ViewEnum.LOGIN.getValue());
    }

    @GetMapping(WEB_PRE + "index")
    public ModelAndView index() {
        return toPage(ViewEnum.INDEX.getValue());
    }


    @GetMapping(WEB_PRE + "console")
    public ModelAndView console() {
        return toPage(ViewEnum.CONSOLE.getValue());
    }

    @GetMapping(WEB_PRE + "403")
    public ModelAndView accessDeny() {
        return toPage(ViewEnum.ACCESS_DENY_URL.getValue());
    }

    @GetMapping(WEB_SYSTEM_PREFIX + "main")
    public ModelAndView system() {
        return toPage(ViewEnum.USER.getValue());
    }

    @GetMapping(WEB_MENU_PREFIX + "main")
    public ModelAndView menu() {
        return toPage(ViewEnum.MENU.getValue());
    }

    @GetMapping(WEB_MENU_PREFIX + "edit")
    public ModelAndView menuEdit() {
        return toPage(ViewEnum.MENU_EDIT.getValue());
    }

    @GetMapping(WEB_MENU_PREFIX + "add")
    public ModelAndView menuAdd() {
        return toPage(ViewEnum.MENU_ADD.getValue());
    }

    @GetMapping(WEB_ROLE_PREFIX + "main")
    public ModelAndView role() {
        return toPage(ViewEnum.ROLE.getValue());
    }

    @GetMapping(WEB_ROLE_PREFIX + "add")
    public ModelAndView roleAdd() {
        return toPage(ViewEnum.ROLE_ADD.getValue());
    }

    @GetMapping(WEB_ROLE_PREFIX + "edit")
    public ModelAndView roleEdit() {
        return toPage(ViewEnum.ROLE_EDIT.getValue());
    }

    @GetMapping(WEB_ROLE_PREFIX + "power")
    public ModelAndView rolePower() {
        return toPage(ViewEnum.ROLE_POWER.getValue());
    }

    @GetMapping(WEB_USER_PREFIX + "main")
    public ModelAndView user() {
        return toPage(ViewEnum.USER.getValue());
    }

    @GetMapping(WEB_USER_PREFIX + "edit")
    public ModelAndView userEdit() {
        return toPage(ViewEnum.USER_EDIT.getValue());
    }

    @GetMapping(WEB_USER_PREFIX + "add")
    public ModelAndView userAdd() {
        return toPage(ViewEnum.USER_ADD.getValue());
    }

}
